# -*- coding: utf-8 -*-#
#-------------------------------------------------------------------------------
# Name:         woniusalestest01
# Description:  
# Author:       Administrator
# Date:         2020/2/10
#-------------------------------------------------------------------------------
# 调用工具类的get_txt方法获取配置文件中的信息
from guitest.woniusales_test01.util.utility import Utility
import time
# driver
from guitest.woniusales_test02.util.service import Service

class Driven:

	# 生成driver
	def __init__(self,path):

		# 通过类名访问类方法
		contents = Utility.get_json(path)
		from selenium import webdriver
		# 通过反射机制直接获取浏览器驱动对象
		self.driver =getattr(webdriver, contents['BROWSER'])()
		self.driver.implicitly_wait(10)
		self.driver.maximize_window()

	# 进行相关功能的测试,体现了对测试的组织
	def do_test(self):

		# 执行登录功能的测试
		from guitest.woniusales_test02.testcase.test_login import LoginTest
		# LoginTest(self.driver).test_login('..\\config\\base.conf','..\\config\\testdata.conf')
		# 执行添加会员功能的测试
		# from guitest.woniusales_test02.testcase.test_customer import CustomerTest
		# ct = CustomerTest(self.driver, '..\\config\\testdata.conf', '..\\config\\base.conf')
		# ct.test_add_customer()
		#ct.test_query_customer()
		# ct.test_edit_customer()
		from guitest.woniusales_test02.testcase.test_sales import SalesTest
		st = SalesTest(self.driver,'..\\config\\testdata.conf', '..\\config\\base.conf')
		# st.test_scan_barcode()
		st.test_remove_goods()

if __name__ == '__main__':
	d = Driven('..\\config\\base.conf')
	d.do_test()
	# from selenium import webdriver
	# driver = webdriver.Firefox()
	# driver.implicitly_wait(10)
	# Service.miss_login(driver,'..\\config\\base.conf')
	# driver.find_element_by_link_text('会员管理').click()
	# driver.find_element_by_css_selector('button.form-control:nth-child(3)').click()
	# # customer_list = driver.find_element_by_id('customerlist')
	# customer_list_eles = driver.find_elements_by_xpath('//tbody[@id="customerlist"]'
	#                               '/tr')
	# print(len(customer_list_eles))
